package com.agu.mgt.sys.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.agu.common.tree.OrgNode;
import com.agu.entity.sys.SysOrgEntity;
import com.agu.mgt.sys.dao.SysOrgDao;
import com.agu.mgt.sys.service.SysOrgService;
import com.agu.utils.Query;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;


@Service("sysOrgService")
@Transactional(readOnly = true)
public class SysOrgServiceImpl implements SysOrgService {
	@Autowired
	private SysOrgDao sysOrgDao;
	
	@Override
	public SysOrgEntity queryObject(String orgGuid){
		return sysOrgDao.queryObject(orgGuid);
	}
	
	@Override
	public List<SysOrgEntity> queryList(Map<String, Object> map){
		return sysOrgDao.queryList(map);
	}

    @Override
	public Page<SysOrgEntity> queryPageList(Query query){
	    PageHelper.startPage(query.getPage(), query.getLimit());
	    return sysOrgDao.queryPageList(query);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return sysOrgDao.queryTotal(map);
	}
	
	@Override
	@Transactional
	public void save(SysOrgEntity sysOrg){
		sysOrgDao.save(sysOrg);
	}
	
	@Override
	@Transactional
	public void updatePath(List<OrgNode> treeList) {
		// TODO Auto-generated method stub
		for(OrgNode node:treeList) {
			sysOrgDao.updatePath(node);
		}
		
	}
	
	@Override
	@Transactional
	public void update(SysOrgEntity sysOrg){
		sysOrgDao.update(sysOrg);
	}
	
	@Override
	@Transactional
	public void delete(String orgGuid){
		sysOrgDao.delete(orgGuid);
	}
	
	@Override
	@Transactional
	public void deleteBatch(String[] orgGuids){
		sysOrgDao.deleteBatch(orgGuids);
	}


	
}
